version: '2.4'

services:
  application:
    build:
      context: .
    environment:
      CASSANDRA_HOST: database
      CASSANDRA_USER: cassandra
      CASSANDRA_PASSWORD: cassandra
      SERVICE_STORAGE_ID: 0
    ports:
      - "8000:80"
    depends_on:
      database:
        condition: service_healthy

  database:
    image: cassandra:4.1.3
    volumes:
      - db_data:/var/lib/cassandra
    healthcheck:
      test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
      interval: 20s
      timeout: 5s
      retries: 5
      start_period: 60s

volumes:
  db_data:
    driver: local